package day6;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Student {
    private String name;
    private int age;
    private Sex sex;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Sex getSex() {
        return sex;
    }

    public void setSex(Sex sex) {
        this.sex=sex;
//        if (sex.equals("男") || sex.equals("女"))
//            this.sex = sex;
//        else
//            throw new RuntimeException("sex error");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                '}';
    }

    public static void main(String[] args) {
        System.out.println(Sex.人妖.name());
        System.out.println(Sex.人妖.ordinal());
        Student s=new Student();
        Scanner sc=new Scanner(System.in);
        System.out.println("输入名字：");
        s.setName(sc.next());
        System.out.println("输入年龄：");
        s.setAge(sc.nextInt());
        System.out.println("输入性别：");
        s.setSex(Sex.valueOf(sc.next()));//静态方法。。。
        System.out.println(s);

    }
}
